using UnityEngine;

public class DeadPlayerInCollider : MonoBehaviour
{
	public float deadTime = 0.2f;

	private void OnTriggerEnter(Collider other)
	{
		if (other.tag == "Player" && other.gameObject == GameController.instance.myPlayer)
		{
			if (settings.offlineMode)
			{
				Invoke("DeadOffinde", deadTime);
			}
			else
			{
				Invoke("DeadOnline", deadTime);
			}
		}
	}

	private void OnTriggerExit(Collider other)
	{
		if (other.tag == "Player" && other.gameObject == GameController.instance.myPlayer)
		{
			if (settings.offlineMode)
			{
				CancelInvoke("DeadOffinde");
			}
			else
			{
				CancelInvoke("DeadOnline");
			}
		}
	}

	private void DeadOffinde()
	{
		GameController.instance.playerScript.Kill();
	}

	private void DeadOnline()
	{
		GameController.instance.playerScript.photonView.RPC("Kill", PhotonTargets.All, GameController.instance.playerScript.viewId);
	}
}
